Practical Data Analysis by Unknown

Practical Data Analysis by Unknown

Author:Unknown
Language: eng
Format: epub, pdf
Publisher: Packt Publishing


Solving ordinary differential equation for the SIR model with SciPy

In order to observe the morphology of an infectious disease outbreak, we need to solve the SIR model. In this case, we will use the integrate method of the SciPy module to solve the ODE. In Appendix, Setting Up the Infrastructure, we can find the installation instructions for SciPy.

First, we need to import the required libraries scipy and pylab.

import scipy import scipy.integrate import pylab as plt

Then, we will define the SIR_model function, which will contain the ODE, with beta representing the transmission probability, gamma as the infected period, X[0] representing the susceptible population, and X[1] representing the infected population:

beta = 0.003 gamma = 0.1 def SIR_model(X, t=0): r = scipy.array([- beta*X[0]*X[1] , beta*X[0]*X[1] - gamma*X[1] , gamma*X[1] ]) return r



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.